package org.ocelot.tunes4j.gui;

import java.awt.Cursor;
import java.awt.Insets;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.net.URL;

import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JOptionPane;
import javax.swing.JTextField;



public class Testing  {  
    public static void main(String[] args) throws IOException {  
        URL url = Testing.class.getResource("../icons/close.png");  
        final BufferedImage image = ImageIO.read(url);  
//        Border border = UIManager.getBorder("TextField.border");  
//        final int x0 = border.getBorderInsets(new JTextField()).left;  
//        JTextField textField = new JTextField() {  
//            protected void paintComponent(Graphics g) {  
//                super.paintComponent(g);  
//                int y = (getHeight() - image.getHeight())/2;  
//                g.drawImage(image, x0, y, this);  
//            }  
//        };  
//        System.out.printf("insets = %s%n",  
//                           border.getBorderInsets(textField));  
//        textField.setMargin(new Insets(0, x0 + image.getWidth(), 0, 0));  
    	JTextField jt = new JTextField("TextField");
    	JButton    jb = new JButton(new ImageIcon(image));
    	jb.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));  
    	jb.setContentAreaFilled(false);
    	jb.setBorderPainted(false);
    	jb.setFocusPainted(false);
    	jt.setMargin(new Insets(0,20,1,1));
    	jb.setBounds(2,2,16,16);
    	jt.add(jb);
        JOptionPane.showMessageDialog(null, jt, "", JOptionPane.PLAIN_MESSAGE);  
    }  
}  